<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app" style="padding-left: 200px">
    <div style="height: 300px;width: 165px;border: #adadad 1px solid">
    <input type="text" v-model="inpex" @keyup.enter="add">
    <ul>
        <li v-for="(it,index) in list">
          {{ index+1 }}.      {{ it }}
        <a @click="remove(index)">x</a>
        </li>

    </ul>

       <span v-if="list.length!=0">{{ list.length }}</span>
        <a v-show="list.length!=0" style="padding-left: 100px" @click="qk">清除</a>
</div>

</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    var app=new Vue({
        el:"#app",
        data:{
          list:["吃饭","睡觉","看电视"],
            inpex:"好好"
        },
        methods:{
            add:function () {
                this.list.push(this.inpex)
            },
            remove:function (p1) {
                this.list.splice(p1,1)
            },
            qk:function () {
                this.list=[];
            }

        }

    })

</script>
</body>
</html>